package com.example.tianyidemo.controller;
import com.example.tianyidemo.pojo.Comment;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.service.CommentServriver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class GetcommentController {
    @Autowired
    private CommentServriver commentServriver;
    @ResponseBody
    @GetMapping("/getcomment")
    public Result getcommentList(){
        List<Comment> commentList = commentServriver.getcomment();
        return Result.success(commentList);
    };
}
